package lsl.leetCode.year2023.test0127;

public class test556 {
    public static void main(String[] args) {
        int[][] a = {{1, 2, 8}, {3, 4, 6}};
        matrixReshape(a, 1, 6);
        System.out.println(a[1][2]);
    }

    public static int[][] matrixReshape(int[][] mat, int r, int c) {
        //行数
        int i = mat.length;
        //列数
        int j = mat[0].length;
        if (i * j != r * c) {
            return mat;
        }
        int[][] ans = new int[r][c];
        for (int x = 0; x < i * j; ++x) {
            ans[x / c][x % c] = mat[x / j][x % j];
        }
        return ans;
    }
}
